package vno.fux.map
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.geom.Point;
	import vno.fux.BasePoint;
	
	
	public class MapModel extends EventDispatcher
	{
		private var _id:uint;
		private var _resourceId:uint;
		private var _width:uint;
		private var _height:uint;
		private var _speed:Number;
		private var _ox:Number;
		private var _oy:Number;
		private var _tileWidth:uint;
		private var _tileHeight:uint;
		private var _tileNumX:uint;
		private var _tileNumY:uint;
		private var _gridNumX:uint;
		private var _gridNumY:uint;
		private var _gridCellSize:uint;
		//private var _grid:MapGrid;
		private var _gridMatrix:Vector.<Vector.<int>>;
		
		public function MapModel(opts:Object) 
		{
			_id 		= opts["id"]?				opts["id"]				:0;
			_resourceId = opts["resourceId"]?		opts["resourceId"]		:0;
			_width 		= opts["width"]?			opts["width"]			:0;
			_height 	= opts["height"]?			opts["height"]			:0;
			_speed 		= opts["speed"]?			opts["speed"]			:0;
			_ox 		= opts["ox"]?				opts["ox"]				:0;
			_oy 		= opts["oy"]?				opts["oy"]				:0;
			_tileWidth 	= opts["tileWidth"]?		opts["tileWidth"]		:0;
			_tileHeight = opts["tileHeight"]?		opts["tileHeight"]		:0;
			_tileNumX 	= opts["tileNumX"]?			opts["tileNumX"]		:0;
			_tileNumY 	= opts["tileNumY"]?			opts["tileNumY"]		:0;
			_gridNumX	= opts["gridNumX"]?			opts["gridNumX"]		:0;
			_gridNumY	= opts["gridNumY"]?			opts["gridNumY"]		:0;
			_gridMatrix	= opts["gridMatrix"]?		opts["gridMatrix"]		:null;
			_gridCellSize	= opts["gridCellSize"]?	opts["gridCellSize"]	:0;
		}
		public function update():void
		{
			dispatchEvent(new Event(Event.CHANGE));
		}
		public function set id(value:uint):void
		{
			_resourceId = value;
		}
		public function get width():uint
		{
			return _width;
		}
		public function set width(value:uint):void
		{
			_width = value;
		}
		public function get height():uint
		{
			return _height;
		}
		public function set height(value:uint):void
		{
			_height = value;
		}
		public function get ox():Number
		{
			return _ox;
		}
		public function set ox(value:Number):void
		{
			_ox = value;
		}
		public function get oy():Number
		{
			return _oy;
		}
		public function set oy(value:Number):void
		{
			_oy = value;
		}
		public function get tileWidth():uint
		{
			return _tileWidth;
		}
		public function set tileWidth(value:uint):void
		{
			_tileWidth = value;
		}
		public function get tileHeight():uint
		{
			return _tileHeight;
		}
		public function set tileHeight(value:uint):void
		{
			_tileHeight = value;
		}
		public function get tileNumX():uint
		{
			return _tileNumX;
		}
		public function set tileNumX(value:uint):void
		{
			_tileNumX = value;
		}
		public function get tileNumY():uint
		{
			return _tileNumY;
		}
		public function set tileNumY(value:uint):void
		{
			_tileNumY = value;
		}
		public function get speed():Number
		{
			return _speed;
		}
		public function set speed(value:Number):void
		{
			_speed = value;
		}

		public function get id():uint
		{
			return _id;
		}
		public function get resourceId():uint
		{
			return _resourceId;
		}
		public function set resourceId(value:uint):void
		{
			_resourceId = value;
		}
		public function get oPoint():BasePoint
		{
			return new BasePoint(ox,oy);
		}
		public function get gridMatrix():Vector.<Vector.<int>>
		{
			return _gridMatrix;
		}
		public function set gridMatrix(value:Vector.<Vector.<int>>):void
		{
			_gridMatrix = value;
		}
		public function get gridNumX():uint
		{
			return _gridNumX;
		}
		public function set gridNumX(value:uint):void
		{
			_gridNumX = value;
		}
		public function get gridNumY():uint
		{
			return _gridNumY;
		}
		public function set gridNumY(value:uint):void
		{
			_gridNumY = value;
		}
		public function get gridCellSize():uint
		{
			return _gridCellSize;
		}
		public function set gridCellSize(value:uint):void
		{
			_gridCellSize = value;
		}
	}
}